package time.after.time.web;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.struts2.ServletActionContext;
import org.springframework.beans.factory.annotation.Autowired;

import time.after.time.entity.account.User;
import time.after.time.service.account.AccountManager;

import com.opensymphony.xwork2.ActionSupport;

public abstract class BaseActionSupport extends  ActionSupport{

	private static final long serialVersionUID = 1L;
	
//	protected ServletContext application = ServletActionContext.getServletContext();
//	protected String contextPath = application.getContextPath();
	
	protected HttpServletRequest request = ServletActionContext.getRequest();
	protected HttpServletResponse response = ServletActionContext.getResponse();
	protected HttpSession session = request.getSession();
	
	protected Long id;
	@Autowired
	private AccountManager accountManager;
	
	public void setId(Long id) {
		this.id = id;
	}
	
	public Long getMe()
	{
		return (Long)session.getAttribute("ME");
	}
	
	public User getCurrentUser()
	{
		return accountManager.getUser(getMe());
	}
	
}
